/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.actionform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author pavan
 */
public class SupplierMasterFormBean extends org.apache.struts.action.ActionForm {

    private String supplierName, panNo, address, staxNum, phoneNo, staxType, faxNo, monitoryLimit, tandc, location;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getFaxNo() {
        return faxNo;
    }

    public void setFaxNo(String faxNo) {
        this.faxNo = faxNo;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getMonitoryLimit() {
        return monitoryLimit;
    }

    public void setMonitoryLimit(String monitoryLimit) {
        this.monitoryLimit = monitoryLimit;
    }

    public String getPanNo() {
        return panNo;
    }

    public void setPanNo(String panNo) {
        this.panNo = panNo;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }

    public String getStaxType() {
        return staxType;
    }

    public void setStaxType(String staxType) {
        this.staxType = staxType;
    }

    public String getStaxNum() {
        return staxNum;
    }

    public void setStaxnum(String staxNum) {
        this.staxNum = staxNum;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public String getTandc() {
        return tandc;
    }

    public void setTandc(String tandc) {
        this.tandc = tandc;
    }

    /**
     *
     */
    public SupplierMasterFormBean() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getSupplierName() == null || getSupplierName().length() < 1) {
            errors.add("supplierName", new ActionMessage("error.supplierName.required"));
        }
        if (getTandc() == null || getTandc().length() < 1) {
            errors.add("tandc", new ActionMessage("error.tandc.required"));
        }
        if (getStaxNum() == null || getStaxNum().length() < 1) {
            errors.add("staxnum", new ActionMessage("error.staxnum.required"));
        }
        if (getStaxType() == null || getStaxType().length() < 1) {
            errors.add("staxtype", new ActionMessage("error.staxtype.required"));
        }
        if (getPhoneNo() == null || getPhoneNo().length() < 1) {
            errors.add("phoneno", new ActionMessage("error.phoneno.required"));
        }
        if (getPanNo() == null || getPanNo().length() < 1) {
            errors.add("panno", new ActionMessage("error.panno.required"));
        }
        if (getMonitoryLimit() == null || getMonitoryLimit().length() < 1) {
            errors.add("monitorylimit", new ActionMessage("error.monitorylimit.required"));
        }
        if (getLocation().trim().equals("Select") || getLocation().length() < 1) {
            errors.add("location", new ActionMessage("error.location.required"));
        }
        if (getFaxNo() == null || getFaxNo().length() < 1) {
            errors.add("faxno", new ActionMessage("error.faxno.required"));
        }
        if (getAddress() == null || getAddress().length() < 1) {
            errors.add("address", new ActionMessage("error.address.required"));
        }
        return errors;
    }
}
